package il.ac.technion.cs236700.address_book;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/** 
 * 
 * @authors Regev Azriel & Sharon Ronen
 *
 */
public interface FlexibleAddressBook extends AddressBook {

	/**
	 * additional keys for the default ones
	 * @param keys - additional keys
	 */
	public void AddSupportedKeys(ArrayList<String> keys);
	
	/**
	 * Add details to existing person in the address book.
	 * All the keys in details must be supported.
	 * The new details must not appear in the person's old record
	 * (i.e. non overriding add) 
	 * @param p - an already exists person
	 * @param details - additional details
	 */
	public void AddDetails(Person p,Map<String,String> details);
	
	/**
	 * removes a person from the address book (all his instances)
	 * @param p - an already exists person
	 */
	public void Delete(Person p);
	
	/**
	  * removes details of a person from the address book
	  * @param p - an already exists person
	  * @param keys - remove details' keys. all the keys must appear
	  * in the supported keys of the address book 
	  */
	public void DeleteDetails(Person p,String[] keys);
	
	/**
	 * overrides old details with new data (if a key is not 
	 * mention here,the old data remains in the contact) 
	 * @param p - already exist person
	 * @param newDetails - the details which we want to override
	 */
	public void UpdateDetails(Person p,Map<String,String> newDetails);
	
	/**
	  * Adding grouping
	  * @param groupName - fully qualified name,like file system navigation 
	  */
	public void AddGroup(String groupName);
	
	/**
	 * Adding person to group. if the person does not exist in the address book
	 * this method cause additionally adding person to the address book.
	 * if the person exists - adding the person to the group.
	 * multiple group for a person are allowed
	 * @param groupName - fully qualified name,like file system navigation
	 * @param p - a person to be add to groupName
	 */
	public void AddToGroup(String groupName,Person p);
	 
	/**
	 * Gets all the contacts of given group name
	 * @param groupName - fully qualified name,like file system navigation
	 * @return - if groupName exist - list of all the contacts,otherwise null
	 */
	public List<Contact> getGroupContacts(String groupName);
	
	/**
	 * Gets all the groups which the person belong to
	 * @param p - already exist person 
	 * @return - list of group names
	 */
	public List<String> getContainedGroups(Person p);
	
	/**
	 * Removes a group
	 * @param groupName -  already exist group
	 */
	public void DeleteGroup(String groupName);
	
	/**
	  * Remove person from group
	  * @param groupName - fully qualified name,like file system navigation
	  * @param p - already exist person  in the group
	  */
	public void RemoveFromGroup(String groupName,Person p);
	
	/**
	 * Searching for all contacts with first or last name that starts with the 
	 * specified string
	 * @param name 
	 * @return -  CSV string represents the list of all contacts which 
	 * 			  the given string name is a start of the first/last
	 * 			  name of a contact.
	 * 			  the returned CSV's lines are ordered according to {@link Contact#compareTo(Contact)}
	 * 
	 */
	public String Search(String name); 
	
	/**
	 * Searching for particular person
	 * @param p -  already exist person 
	 * @return - A CSV string of the searching person
	 */
	public String SearchForPerson(Person p);
	
	/**
	 * Searching for all contacts' values for the key parameter
	 * @param key
	 * @return List of all the values sorted in a lexicographic order 
	 */
	public ArrayList<String> SearchAccordingToKey(String key);
	
	/**
	 * Searching for all contacts that contains all the pairs in the map
	 * @param map
	 * @return A CSV string of all the contacts.
	 * 		   the returned CSV's lines are ordered according to {@link Contact#compareTo(Contact)}
	 */
	public String Search(Map<String,String> map);
	
	
}
